﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{
    ViewBag.Title = "Samples";
}

<h2>@ViewBag.Title</h2>
<h3>@ViewBag.Message</h3>

@if (ViewBag.Error != null)
{
    <div><b>@ViewBag.Error</b></div>
    <div>@ViewBag.ErrorDetail</div>
    <div></div>
}

<div>
    <br/>
    <b>Find similar samples</b><br />
    <form action="~/Samples/getsamplesbtp" method="post" enctype="multipart/form-data">
        <table>
            <tr>
                <td height="30" width="300">
                    Select your sample in CSV (";" separated) file:
                </td>
                <td>
                    <input type="file" name="file" id="file" />
                </td>
            </tr>
            <tr>
                <td height="30">
                    Tolerance:
                </td>
                <td>
                    <input id="tolerance" name="tolerance" type="text" style="width:70px;" />
                </td>
            </tr>
            <tr>
                <td height="30">
                    Ratio tolerance:
                </td>
                <td>
                    <input id="rtolerance" name="rtolerance" type="text" style="width:70px;" />
                </td>
            </tr>
            <tr>
                <td height="30">
                    Graph type:
                </td>
                <td>
                    <select id="chart" name="chart" style="width:95px;">
                        <option value="Column" selected="selected">Column</option>
                        <option value="Line">Line</option>
                        <option value="Point">Point</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td height="30" colspan="2">
                    <input type="submit" value="Find" style="width:100px;" />
                </td>
            </tr>
        </table>
    </form>
</div>

@if (ViewBag.simSample != null && ViewBag.resCount != null)
{
    <hr>

    var simSample = (DDBS_Server.Models.Sample)ViewBag.simSample;

    <div>
        @simSample.Details();
        <br />
        <hr>
    </div>
    <div>
        @for (int i = 0; i < ViewBag.resCount; i++)
        {
            @RenderChart(i)
            <br/>
            <a href="~/Samples/Sample/@ViewBag.sids[i]" target="_blank" style="position: relative; left: 20px">Download sample</a>
            <br/>
            <hr>
        }
    </div>
}

@helper RenderChart(int i)
{
    <img src="@Url.Action("Chart", new { i=i })" alt="" />
}

